home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / amos / AMCAFExa.lha / AMCAF_Examples / Ham.AMOS / Ham.amosSourceCode
Encoding:
AMOS Source Code  |  1996-01-17  |  4.4 KB  |  126 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Ham Fade           =Glue Colour
  3. ' *           Amcaf Examples          * =Ham Colour        Turbo Point 
  4. ' *         Ham Commands V1.0         * =Ham Best          Turbo Plot
  5. ' *      Written by Chris Hodges      * =Red Val           =Mix Colour 
  6. ' *                                   * =Green Val 
  7. ' ************************************* =Blue Val
  8. '
  9. ' Let's load a ham-picture.
  10. Load Iff "Data/AMCAFHam.iff",0
  11. ' So... I want to recolour it. 
  12. ' To keep the program compatible with other screen sizes, I copy the 
  13. ' dimensions into the variables WX and WY. 
  14. WX=Screen Width
  15. WY=Screen Height
  16. ' We need two loops to readout every dot on the screen.
  17. ' Because I think you are quite impatient, I only change the upper quater. 
  18. For Y=0 To WY/4-1
  19.   ' As this is the beginning of a new horizontal line, I must reset some 
  20.   ' variables. HAM1 holds the composite colour information of the old original 
  21.   ' screen datas in the format $RGB. 
  22.   ' And so HAM1 must be set to Colour(0).  
  23.   HAM1= Colour(0) : HAM2=HAM1
  24.   For X=0 To WX-1
  25.     ' The next instruction reads the pixel from the coords x,y.
  26.     P= Extension_8_039E(X,Y)
  27.     ' Now let's calculate the effect of this pixel. Therefore I must give
  28.     ' the composite colour of the pixel before.
  29.     HAM1= Extension_8_09E8(P,HAM1)
  30.     ' Split the new value into the three components
  31.     RED= Extension_8_03B2(HAM1)
  32.     GREEN= Extension_8_03C0(HAM1)
  33.     BLUE= Extension_8_03D0(HAM1)
  34.     ' Now let's modify some values:
  35.     ' Add 4 to the RED value, but keep track of the maximum. 
  36.     RED=Min(RED+4,15)
  37.     ' Invert all GREEN shapes. 
  38.     GREEN=15-GREEN
  39.     ' And at last sub 2 from the BLUE value. 
  40.     BLUE=Max(BLUE-2,0)
  41.     ' Build the new composite colour 
  42.     NEW= Extension_8_0A0E(RED,GREEN,BLUE)
  43.     ' Now I must search the best colour for changing the picture.
  44.     ' To do this, I call =Ham Best with the old colour, and the
  45.     ' colour, I want to have as result.
  46.     P= Extension_8_09FC(NEW,HAM2)
  47.     ' Rewrite the pixel
  48.      Extension_8_0388 X,Y,P
  49.     ' Calculate the real effect of that modification.
  50.     HAM2= Extension_8_09E8(P,HAM2)
  51.   Next 
  52. Next 
  53. ' Now I want to blend out this ham-pic.  
  54. ' So Ham Fade Out is used. 
  55. ' Every time it's been called, the screen gets one darker. After 16 calls
  56. ' the screen is completely black.
  57. For A=0 To 15
  58.   ' Synchronise with the raster beam.
  59.   Wait Vbl 
  60.   ' And fade...
  61.    Extension_8_0FBA 0
  62. Next 
  63. Screen Close 0
  64. ' Close the screen nicely :) 
  65. '
  66. ' There are so many other possibilities about what you can do with the ham 
  67. ' commands, but I only will take one out: Mixing two normal pictures into
  68. ' one ham screen.
  69. ' Load a new 32 colours picture. 
  70. Load Iff "Data/Weazle.iff",0 : Screen Hide 
  71. ' Get the dimensions of the screen.
  72. WX1=Screen Width
  73. WY1=Screen Height
  74. ' Load the second one and get width and height.
  75. Load Iff "Data/Beach.iff",1 : Screen Hide 
  76. WX2=Screen Width
  77. WY2=Screen Height
  78. ' Calculate the size of the new screen. Therefore the mininum value of both
  79. ' is taken.
  80. WX=Min(WX1,WX2)
  81. WY=Min(WY1,WY2)
  82. ' Now open the third screen. Note that this one is HAM.
  83. Screen Open 2,WX,WY,4096,Lowres
  84. Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 0
  85. ' Then the palettes should be mixed to get better results, but it is NOT 
  86. ' neccessary at all! 
  87. ' First I copy the whole palette from screen 0.
  88. Get Palette 0
  89. ' In a loop I take each colour and mix it using the Mix Colour function. 
  90. For A=0 To 31
  91.   Screen 1
  92.   C1= Colour(A)
  93.   Screen 2
  94.   C2= Colour(A)
  95.   Colour A, Extension_8_0EE8(C1,C2)
  96. Next 
  97. ' Now comes the main part. It's quite similar to the upper part. 
  98. For Y=0 To WY-1
  99.   ' At the beginning of a line, set the old colour to the border colour, 
  100.   ' that is Colour(0). 
  101.   HAM= Colour(0)
  102.   For X=0 To WX-1
  103.     ' Get pixel x,y of screen 0. 
  104.     Screen 0
  105.     P1= Extension_8_039E(X,Y)
  106.     ' Get the composite colour.
  107.     C1= Colour(P1)
  108.     ' Get pixel x,y of screen 1 and composite colour.  
  109.     Screen 1
  110.     P2= Extension_8_039E(X,Y)
  111.     C2= Colour(P2)
  112.     ' Mix these colours. 
  113.     NEW= Extension_8_0EE8(C1,C2)
  114.     ' Don't forget to change to the ham screen, as Ham Best gets the palette 
  115.     ' from the current screen, and that must be the ham screen.
  116.     Screen 2
  117.     ' Now calculate the best ham colour. As always, we need the colour of the
  118.     ' previous pixel.
  119.     P= Extension_8_09FC(NEW,HAM)
  120.     ' Write the new pixel to the screen
  121.      Extension_8_0388 X,Y,P
  122.     ' And at last, calculate the real colour change. 
  123.     HAM= Extension_8_09E8(P,HAM)
  124.   Next 
  125. Next 
  126. End